package com.service.impl;

import com.mapper.entity.StockCirculation;
import com.mapper.entity.StockCirculationDetail;
import com.mapper.entity.StockCirculationDetailOrg;
import com.service.stock.detail.IStockOrgInstanceToStockDetail;
import com.service.stock.detail.impl.StockOrgInstanceToChannelStockDetail;
import com.service.stock.detail.impl.StockOrgInstanceToInStockDetail;
import com.service.stock.detail.impl.StockOrgInstanceToOutStockDetail;
import com.service.stock.impl.BaseStockOrgInstanceToStock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: create by God of SJF
 * @version: v1.0
 * @description: com.service.impl
 * @date:2021/9/16
 */

@Component
public class StockAdapter {

    @Autowired
    BaseStockOrgInstanceToStock baseStockOrgInstanceToStock;

    @Autowired
    StockOrgInstanceToInStockDetail stockOrgInstanceToInStockDetail;

    @Autowired
    StockOrgInstanceToOutStockDetail stockOrgInstanceToOutStockDetail;

    @Autowired
    StockOrgInstanceToChannelStockDetail stockOrgInstanceToChannelStockDetail;

    public StockCirculationDetail detail(StockCirculationDetailOrg org) {
        IStockOrgInstanceToStockDetail iStockOrgInstanceToStockDetail = null;
        if (org.get_status() == 1L || org.get_status() == 6L) {
            iStockOrgInstanceToStockDetail = stockOrgInstanceToInStockDetail;
        } else if (org.get_status() == 2L || org.get_status() == 3L) {
            iStockOrgInstanceToStockDetail = stockOrgInstanceToOutStockDetail;
        } else {
            iStockOrgInstanceToStockDetail = stockOrgInstanceToChannelStockDetail;
        }
        return  iStockOrgInstanceToStockDetail.instance(org);
    }

    public StockCirculation stock(StockCirculationDetailOrg org){
        return baseStockOrgInstanceToStock.instance(org);
    }

}
